package valueobject

// MoveState 移动状态值对象
type MoveState struct {
	fromPosX float32 // 起始X坐标
	fromPosY float32 // 起始Y坐标
	toPosX   float32 // 目标X坐标
	toPosY   float32 // 目标Y坐标
	startTime int64  // 开始移动时间
}

// NewMoveState 创建新的移动状态
func NewMoveState() *MoveState {
	return &MoveState{
		fromPosX:  0,
		fromPosY:  0,
		toPosX:    0,
		toPosY:    0,
		startTime: 0,
	}
}

// NewMoveStateWithPositions 创建带位置信息的移动状态
func NewMoveStateWithPositions(fromX, fromY, toX, toY float32, startTime int64) *MoveState {
	return &MoveState{
		fromPosX:  fromX,
		fromPosY:  fromY,
		toPosX:    toX,
		toPosY:    toY,
		startTime: startTime,
	}
}

// GetFromPosX 获取起始X坐标
func (ms *MoveState) GetFromPosX() float32 {
	return ms.fromPosX
}

// GetFromPosY 获取起始Y坐标
func (ms *MoveState) GetFromPosY() float32 {
	return ms.fromPosY
}

// GetToPosX 获取目标X坐标
func (ms *MoveState) GetToPosX() float32 {
	return ms.toPosX
}

// GetToPosY 获取目标Y坐标
func (ms *MoveState) GetToPosY() float32 {
	return ms.toPosY
}

// GetStartTime 获取开始移动时间
func (ms *MoveState) GetStartTime() int64 {
	return ms.startTime
}

// SetFromPosition 设置起始位置
func (ms *MoveState) SetFromPosition(x, y float32) {
	ms.fromPosX = x
	ms.fromPosY = y
}

// SetToPosition 设置目标位置
func (ms *MoveState) SetToPosition(x, y float32) {
	ms.toPosX = x
	ms.toPosY = y
}

// SetStartTime 设置开始移动时间
func (ms *MoveState) SetStartTime(startTime int64) {
	ms.startTime = startTime
}

// IsMoving 判断是否正在移动
func (ms *MoveState) IsMoving() bool {
	return ms.fromPosX != ms.toPosX || ms.fromPosY != ms.toPosY
}

// Reset 重置移动状态
func (ms *MoveState) Reset() {
	ms.fromPosX = 0
	ms.fromPosY = 0
	ms.toPosX = 0
	ms.toPosY = 0
	ms.startTime = 0
}

// Copy 复制移动状态
func (ms *MoveState) Copy() *MoveState {
	return &MoveState{
		fromPosX:  ms.fromPosX,
		fromPosY:  ms.fromPosY,
		toPosX:    ms.toPosX,
		toPosY:    ms.toPosY,
		startTime: ms.startTime,
	}
}